import React, { useEffect } from 'react';
import DatePickerNa from './DatePickerNa';
import { Button, Form } from 'antd';
import { WrappedFormUtils } from 'antd/lib/form/Form';

interface IProps {
    form: WrappedFormUtils;
}

const Index = ({ form }: IProps) => {
    const { getFieldDecorator, validateFields, setFieldsValue } = form || {};

    const submit = () => {
        validateFields((err, values) => {
            if (!err) {
                console.log(values);
            }
        });
    };

    // useEffect(() => {
    //     setFieldsValue({
    //         data: 'NA',
    //     });
    // }, []);

    return (
        <>
            <DatePickerNa />
            <hr />
            <Form>
                <Form.Item label={'riqi'}>
                    {getFieldDecorator('data', {
                        rules: [
                            {
                                required: true,
                            },
                        ],
                        initialValue: {
                            date: undefined,
                            isNA: true,
                        },
                    })(<DatePickerNa />)}
                </Form.Item>
            </Form>
            <Button onClick={submit}>信息保存</Button>
        </>
    );
};

export default Form.create({ name: 'datePickTime' })(Index);
